package com.order.dao.bean;

import com.order.dao.DBUtil;
import com.order.dao.OrderDBUtil;

public class Manager{
	
	public boolean validate(String mname,String mpw)
	{
		String pw=DBUtil.getpd(mname);
		//System.out.println(pw);
		if(mpw.equals(pw)&&pw!=null)
		{
			return true;
		}
		else
		{
		return false;	
		}
		
	}
	public boolean delmanager(String id){
		int c=0;
		if(!(OrderDBUtil.isHasFKWaiterid(id))){
		if(id!=null){
			String sql="delete from manager where managerid='"+id+"'";
			c=DBUtil.UpdateUserInfo(sql);
			if(c>0)return true;
			else return false;
		}
		else
			  return false;
		}
		else
			  return false;
	}
	public  boolean insertmanager(String id,String name,String password){
		String sql=null;
        sql=  "insert into manager values('"+id+"'";
	    sql+= ",'" + name + "','" + password +  "')";
	    System.out.println(sql);
	    int c=DBUtil.UpdateUserInfo(sql);
	    if(c>0)return true;
	    else 
	    	return false;
	    
	}
	
	public  boolean updatemanager(String id,String name,String password)
    	{
		int c=0;
		String sql= "update manager set managername='" + name +"',managerpassword='" + password + "' where managerid='"+id+"'";
		c=DBUtil.UpdateUserInfo(sql);
		System.out.println(sql);
		if(c>0)return true;
		else 
			return false;
    	}
}